package com.sudoku.screen;

import java.util.ArrayList;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Screen;

public class TransitionScreen implements Screen {
    Game game;

    Screen current;
    Screen next;

    int currentTransitionEffect;
    ArrayList<TransitionEffect> transitionEffects;
    private float alpha;

    public TransitionScreen(Game game, Screen current, Screen next, ArrayList<TransitionEffect> transitionEffects) {
        this.current = current;
        this.next = next;
        this.transitionEffects = transitionEffects;
        this.currentTransitionEffect = 0;
        this.game = game;
        alpha=0;
    }

    void render() {
        
    }

    @Override
    public void render(float delta) {
        if (currentTransitionEffect >= transitionEffects.size()) {
            game.setScreen(next);
            return;
        }
        
        alpha+=delta/(transitionEffects.get(currentTransitionEffect).getDuration());
        transitionEffects.get(currentTransitionEffect).update(delta);
        transitionEffects.get(currentTransitionEffect).render(current, next, alpha);

        if (transitionEffects.get(currentTransitionEffect).isFinished()){
            currentTransitionEffect++;
            alpha=0;
        }
    }

    @Override
    public void resize(int width, int height) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void show() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void hide() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void pause() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void resume() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void dispose() {
        // TODO Auto-generated method stub
        
    }
}
